import { http, request } from './index';
import type { ImageRecord, ImageAnalysisType } from '@/types/image';

export const uploadImage = (formData: FormData) =>
  request<ImageRecord>(http.post('/v1/images/upload', formData, {
    headers: { 'Content-Type': 'multipart/form-data' },
  }));

export const fetchImageRecords = (params?: {
  analysisType?: ImageAnalysisType;
  page?: number;
  size?: number;
}) => request<ImageRecord[]>(http.get('/v1/images', { params }));

export const getImageRecord = (id: string) =>
  request<ImageRecord>(http.get(`/v1/images/${id}`));

export const getImagePreview = (id: string) =>
  http.get<ArrayBuffer>(`/v1/images/${id}/preview`, {
    responseType: 'arraybuffer',
  });

